package com.xz.knowledgeDuplication.thread.state;

/**
 * 优先级 优先级低只是意味着获得概率低
 * @author 召
 * @date 2022-07-20 21:52:17
 */
public class Priority implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + " : " + Thread.currentThread().getPriority());
    }

    public static void main(String[] args) {
        // 主线程默认优先级
        System.out.println(Thread.currentThread().getName() + " : " + Thread.currentThread().getPriority());
        Thread t1 = new Thread(new Priority(), "t1");
        Thread t2 = new Thread(new Priority(), "t2");
        Thread t3 = new Thread(new Priority(), "t3");
        t1.setPriority(1);
        t1.start();
        t2.setPriority(5);
        t2.start();
        t3.setPriority(10);
        t3.start();
    }


}
